package com.afkt.project.ui.widget.stickyheaders.viewholder;


import com.afkt.project.ui.widget.stickyheaders.model.HeaderModel;
import com.afkt.project.ui.widget.stickyheaders.ultimateprovider.EventTransmissionListener;
import com.afkt.project.ui.widget.stickyheaders.ultimateprovider.UltimateProvider;
import com.afkt.project.ui.widget.stickyheaders.ultimateprovider.ViewHolder;
import com.ohos.afkt.ResourceTable;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.DependentLayout;
import ohos.agp.components.Text;
import ohos.agp.components.element.ShapeElement;

public class HeaderViewHolder extends ViewHolder<HeaderModel> {
    private DependentLayout headerLayout;
    private Text tvTitle;

    public HeaderViewHolder(EventTransmissionListener eventTransmissionListener, Component component, UltimateProvider provider, ComponentContainer componentContainer) {
        super(eventTransmissionListener, component, provider, componentContainer);
        headerLayout = (DependentLayout) findComponentById(ResourceTable.Id_headerLayout);
        tvTitle = (Text) findComponentById(ResourceTable.Id_tv_title);
    }

    @Override
    public void onDataBound() {
        tvTitle.setText(getModel().getTitle());
        int[] padding = getModel().getPaddings();
        tvTitle.setPadding(padding[0], padding[1], padding[2], padding[3]);
        ShapeElement element = new ShapeElement();
        RgbColor rgbColor = new RgbColor(0, 255, 255);
        element.setRgbColor(rgbColor);
        headerLayout.setBackground(element);
    }

}
